package com.sdtv.mediunfusion.mvp.ui.meltcall.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sdtv.basemodule.image.ImageLoaderDelegate;
import com.sdtv.mediunfusion.R;
import com.sdtv.mediunfusion.bean.MeltCallBean;

import java.util.List;

/**
 * @ProjectName: MediunFusion
 * @Package: com.sdtv.mediunfusion.mvp.ui.meltcall.adapter
 * @ClassName: CallListAdapter
 * @Description: 通话记录列表适配器
 * @Author: 小郭同学
 * @CreateDate: 2019-08-01 14:10
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CallListAdapter extends BaseQuickAdapter<MeltCallBean, BaseViewHolder> {

    /**
     * 构造器
     *
     * @param layoutResId 布局文件 数据
     * @param data
     */
    public CallListAdapter(int layoutResId, @Nullable List<MeltCallBean> data) {
        super(layoutResId, data);
    }

    /**
     * 设置每一项的内容
     *
     * @param helper
     * @param item
     */
    @Override
    protected void convert(@NonNull BaseViewHolder helper, MeltCallBean item) {
        // 设置头像
        ImageView imageView = helper.getView(R.id.meidiaimg);
        ImageLoaderDelegate.processor.loadImgWithRadius(mContext,
                imageView, item.getRecordImg(), 8);
        helper.setText(R.id.media_time, item.getRecordTime())
                .setText(R.id.melt_call_date, item.getRecordDate());
        if ("SUCCESS".equals(item.getRecordStatus())) {
            helper.setImageResource(R.id.call_status, R.mipmap.yijielaidian)
                    .setText(R.id.call_total_time, item.getRecordLength())
                    .setTextColor(R.id.call_total_time, Color.parseColor("#888888"))
                    .setTextColor(R.id.media_time, Color.parseColor("#888888"));
        } else {
            helper.setImageResource(R.id.call_status, R.mipmap.weijielaidian)
                    .setText(R.id.call_total_time, "未接连线")
                    .setTextColor(R.id.call_total_time, Color.parseColor("#888888"))
                    .setTextColor(R.id.media_time, Color.parseColor("#888888"));
        }

    }
}
